<template>
    <XPTable ref='tableRef' :api='pageApi' :columns='columns'>
        <template #name='{record}'>
            <router-link :to='"/strategy/detail/" + record.id'>{{record.name}}</router-link>
        </template>
        <template #type='{record}'>
            <a-tag color='#108ee9'>{{record.type}}</a-tag>
        </template>
        <template #test_count='{record}'>
            <router-link :to='"/strategy/backTest/" + record.id'>{{record.test_count}}</router-link>
        </template>
    </XPTable>
</template>

<script lang='ts' setup>
    import { reactive, ref } from 'vue'
    import { myStrategyPageApi } from '@/api/strategy'
    import { Column } from '../../../types'
    async function pageApi(params:any) {
        return myStrategyPageApi(params)
    }

    const columns = reactive<Column[]>([
        {title : '名称', dataIndex : 'name', align : 'center', inFilter : true, filter : {name : 'keyword'}},
        {title : '分类', dataIndex : 'type', align : 'center'},
        {title : '创建时间', dataIndex : 'created_at', align : 'center'},
        {title : '历史回测', dataIndex : 'test_count', align : 'center'},
    ])
</script>
